import React, { useState, useEffect } from 'react'

export default function Demo() {
  let [count, setCount] = useState(0);
  useEffect(() => {
    console.log('第一次渲染结束后（componentDidMount）执行');
    return () => {
      console.log('在组件卸载时（componentWillUnmount）执行');
    }
  }, []);

  useEffect(() => {
    console.log('每一次渲染结束后（componentDidMount 和 componentDidUpdate）执行');

  })

  useEffect(() => {
    console.log('依赖值每次更新渲染结束后（componentDidUpdate）执行');
  }, [count])

  return (
    <div>
      计数：  {count} <button onClick={() => {
        let i = count;
        i++;
        setCount(i);
      }}>+</button>
    </div>
  )
}

